﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using DTO;
namespace DAO
{
    public class CTHoaDonDAO
    {
        public OleDbDataAdapter LayTatCaCTHoaDon(int MaHD)
        {
            OleDbConnection conn = DataProvider.ConnectDB();
            conn.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select MaHD,MaSP,SoHD,TenSP,SoLuong,DonGia,ThanhTien,DiemCV from CTHoaDon where MaHD=1" + MaHD.ToString(), conn);
            conn.Close();
            return da;
        }
        public double TongTien(int MaHD)
        {
            OleDbConnection conn = DataProvider.ConnectDB();
            conn.Open();
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select SUM(ThanhTien) from CTHoaDon where MaHD="+MaHD.ToString();
            double tt = (double)cmd.ExecuteScalar();
            return tt;
        }
        public int TongCV(int MaHD2)
        {
            OleDbConnection conn = DataProvider.ConnectDB();
            conn.Open();
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select SUM(ThanhTien) from CTHoaDon where MaHD=" + MaHD2.ToString();
            int tcv = (int)cmd.ExecuteScalar();
            return tcv;
        }

    }
}
